<div class="page-header">
	<ul id="table-tab" class="nav nav-tabs" role="tablist">
		<li role="presentation" class="">
			<a href="#role-tab" aria-controls="role-tab" role="tab" data-toggle="tab">角色管理</a>
		</li>
	</ul>
</div>

<div class="tab-content">
	<div id="role-tab" class="tab-pane" role="tabpanel">
		<div class="row">
        <!--搜索域-->
        <div class="col-xs-12">
        	<div class="search-area">
        		<form id="table-role-search" class="form-inline">
                 	<div class="form-group">
                    	<label for="role.name">角色名称：</label>
                    	<input type="text" class="form-control input-sm" id="role.name" name="role.name" value="" placeholder="">
                 	</div>
                 	<div class="form-group">
                    	<label for="role.name">角色编码：</label>
                    	<input type="text" class="form-control input-sm" id="role.code" name="role.code" value="" placeholder="">
                 	</div>
                 	<button id="btn-role-search" type="button" class="btn btn-info btn-sm no-border">
                 		<i class="ace-icon fa fa-search bigger-110"></i>查询
                 	</button>
                 	<div class="form-group pull-right">
						<span>查询方式：</span>
						<label class="radio-inline">
							<input type="radio" name="searchType" value="1" checked="checked" />精确
						</label>
						<label class="radio-inline">
							<input type="radio" name="searchType" value="0" />模糊
						</label>
					</div>
                </form>
            </div>
        </div>
    </div>
	<!-- 数据表格 -->
       <div class="row">
           <div class="col-xs-12">
           	<div id="table-role-toolbar">
           		<div class="btn-group btn-group-sm">
           			<!--
                    <button id="viewrole" class="btn btn-purple btn-sm no-border" >
                        <i class="ace-icon fa  fa-eye bigger-110 "></i>查看
                    </button>
                    <button id="addRole" class="btn btn-info btn-sm no-border" 
                    onclick="goAdd('新增角色', 'system/admin/role/add', 'table-role');">
                        <i class="ace-icon fa fa-plus bigger-110"></i>新增
                    </button>
                    <button id="editRole" class="btn btn-success btn-sm no-border"
                    onclick="goUpdate('编辑角色', 'system/admin/role/edit', 'table-role');">
                        <i class="ace-icon fa fa-pencil-square-o bigger-110"></i>编辑
                    </button>
                    <button id="delRole" class="btn btn-danger btn-sm no-border"
                    onclick="doDels('system/admin/role/deletes', 'table-role');">
                        <i class="ace-icon fa fa-trash-o bigger-110"></i>删除
                    </button>
                    <button id="allocPermission" class="btn btn-success btn-sm no-border"
                    onclick="goAlloc('分配权限', 'system/admin/role/allocPermission');">
                        <i class="ace-icon fa fa-pencil-square-o bigger-110"></i>分配权限
                    </button>
                    -->
                    <x:toolbar menuId="${menuId}" elemIds="addRole,editRole,delRole,allocPermission">
	                </x:toolbar>
                   </div>
               </div>
           	<table id="table-role" 
           			data-toolbar="#table-role-toolbar" 
           			data-sort-name="uuid" 
           			data-sort-order="asc"
           			data-show-columns="true">
           		 <thead>
                       <tr>
                           <th data-field="state" data-checkbox="true"></th>
                           <th data-width="120" data-field="name" data-align="left" data-sortable="false">角色名称</th>
                           <th data-width="120" data-field="code" data-align="left" data-sortable="false">角色编码</th>
                           <th data-field="available" data-align="left" data-sortable="true">是否可用</th>
                       </tr>
                   </thead>
               </table>
           </div>
       </div>
	</div>
</div>

<script type="text/javascript">
$(function(){
	$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
		//e.target // 激活的标签页
		//e.relatedTarget // 前一个激活的标签页
		var tabId = $(e.target).attr('aria-controls');
		if(tabId == "role-tab"){
			initTableList('table-role','system/admin/role/dataGrid', 'table-role-search', 'btn-role-search');
		}
	});
	$('#table-tab a[href="#role-tab"]').tab('show');
});

function goAlloc(title, url){
	var selections = $('#table-role').bootstrapTable("getSelections");
	if (selections !== undefined && selections !== null) {
		if (selections.length === 1) {
			var id = selections[0].uuid;
			url = url + '?roleId=' + id;
			loadModal(url, function(data, status) {
				if (status === "success") {
					changeModalTitle(title);
					showModal();
				} else if (status === "timeout") {
					TipMsg.error("请求超时，请重试!!!", 0);
				}
			});
		} else {
			TipMsg.error("请选择一个角色.", 0);
		}
	} else {
		TipMsg.error("没有可进行分配的角色.", 0);
	}
};
</script>
